Skip to content

feat: exclude health endpoints from tracing#46

Merged
andrest50 merged 3 commits into
mainfrom
tbramwell/LFXV2-1583-exclude-health-endpoints-tracing
May 5, 2026
Merged

feat: exclude health endpoints from tracing#46
andrest50 merged 3 commits into
mainfrom
tbramwell/LFXV2-1583-exclude-health-endpoints-tracing

Conversation

@bramwelt
Copy link
Copy Markdown
Contributor

Summary

  • Add otelhttp.WithFilter to otelhttp.NewHandler to skip span creation for /healthz, /livez, and /readyz Kubernetes probe endpoints
  • Reduces high-volume, low-value trace noise from liveness/readiness probes

Test plan

  • go build ./... passes

Issue: LFXV2-1583

🤖 Generated with Claude Code

Add otelhttp.WithFilter to skip span creation for
/healthz, /livez, and /readyz probe requests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1583
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Copilot AI review requested due to automatic review settings April 27, 2026 20:35
@bramwelt bramwelt requested a review from a team as a code owner April 27, 2026 20:35
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b33c69b8-d126-40fb-8da2-1f091b8a7eff

📥 Commits

Reviewing files that changed from the base of the PR and between 4e742f4 and 8f1ee44.

📒 Files selected for processing (1)
  • main.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • main.go

Walkthrough

OpenTelemetry HTTP instrumentation in main.go now wraps http.DefaultServeMux with otelhttp.NewHandler using a filter that disables tracing/metrics for requests to /livez and /readyz, while leaving instrumentation enabled for other paths.

Changes

OpenTelemetry HTTP Handler Filtering

Layer / File(s) Summary
Instrumentation Wiring
main.go
http.DefaultServeMux is wrapped with otelhttp.NewHandler (was previously wrapped without a filter).
Request Filter Logic
main.go
Added otelhttp.WithFilter predicate that returns false for r.URL.Path == "/livez" or "/readyz", causing those endpoints to be excluded from tracing/metrics.
Contextual Impact
main.go
Handler behavior for all other routes remains instrumented; only /livez and /readyz are skipped.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: exclude health endpoints from tracing' clearly and concisely summarizes the main change: excluding health check endpoints from OpenTelemetry tracing.
Description check ✅ Passed The description is directly related to the changeset, explaining the addition of otelhttp.WithFilter to skip span creation for Kubernetes probe endpoints and the rationale for reducing trace noise.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tbramwell/LFXV2-1583-exclude-health-endpoints-tracing

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces OpenTelemetry trace noise by preventing span creation for Kubernetes probe endpoints on the service’s HTTP listener.

Changes:

  • Wrap http.DefaultServeMux with otelhttp.NewHandler using otelhttp.WithFilter.
  • Skip tracing for /livez and /readyz (and currently also /healthz) requests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread main.go Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
main.go (1)

262-267: Nice trace-noise reduction; consider centralizing probe paths.

Line 263–266 hardcodes probe routes in the filter. Consider moving these paths to a shared constant/set (reused by both handler registration and filter logic) to avoid drift in future endpoint changes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@main.go` around lines 262 - 267, The filter passed into otelhttp.NewHandler
currently hardcodes probe paths ("/healthz", "/livez", "/readyz"); extract these
into a shared constant or set (e.g., a slice or map named probePaths or
probePathSet) and use that shared symbol in both the handler registration and
the otelhttp.WithFilter func logic so the probe list is maintained in one place
and cannot drift between registration and filtering; update the
otelhttp.NewHandler call to reference the shared probePaths/probePathSet and
ensure the same symbol is used wherever the probe endpoints are registered or
checked.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@main.go`:
- Around line 262-267: The filter passed into otelhttp.NewHandler currently
hardcodes probe paths ("/healthz", "/livez", "/readyz"); extract these into a
shared constant or set (e.g., a slice or map named probePaths or probePathSet)
and use that shared symbol in both the handler registration and the
otelhttp.WithFilter func logic so the probe list is maintained in one place and
cannot drift between registration and filtering; update the otelhttp.NewHandler
call to reference the shared probePaths/probePathSet and ensure the same symbol
is used wherever the probe endpoints are registered or checked.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6792171e-a6f2-48c8-953e-2d7156adb938

📥 Commits

Reviewing files that changed from the base of the PR and between f36ca40 and aed8081.

📒 Files selected for processing (1)
  • main.go

Address review comments from copilot-pull-request-reviewer[bot]:

- main.go: remove /healthz from OTel filter; only /livez and /readyz
  are registered in this service (per copilot-pull-request-reviewer[bot])

Resolves 1 review thread.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1583
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
@bramwelt
Copy link
Copy Markdown
Contributor Author

Review Feedback Addressed

Commit: 4e742f4

Changes Made

  • main.go:265: Removed /healthz from the OTel tracing filter — this service only registers /livez and /readyz via http.HandleFunc. fga-sync uses plain net/http (not Goa), so no generated path helpers are available; the remaining string literals match the registered routes exactly (per copilot-pull-request-reviewer[bot])

Threads Resolved

1 of 1 unresolved threads addressed in this iteration.

Copilot AI review requested due to automatic review settings May 5, 2026 19:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread main.go
Comment on lines +262 to +266
handler := otelhttp.NewHandler(http.DefaultServeMux, "fga-sync",
otelhttp.WithFilter(func(r *http.Request) bool {
p := r.URL.Path
return p != "/livez" && p != "/readyz"
}),
@andrest50 andrest50 merged commit 8616224 into main May 5, 2026
12 checks passed
@andrest50 andrest50 deleted the tbramwell/LFXV2-1583-exclude-health-endpoints-tracing branch May 5, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants